import axios from 'axios';
import { loginreq, req } from './axiosFun';

/**
 * 用户管理
 * Author wuzhengru
 * date 2021-03-21
 **/
//用户管理-登录
export const userLogin = (params) => { return loginreq("post", "/api/v1/user/userInfoValid", params) };
//用户管理-注册用户信息验证
export const registerValid = (params) => { return loginreq("post", "/api/v1/user/registerValid", params) };
//用户管理-注册新用户
export const register = (params) => { return loginreq("post", "/api/v1/user/register", params) };
//用户管理-动态验证码生成-登陆后
export const setEmailCode = () => { return axios
({method: 'get',
    url: '/api/v1/user/setEmailCode',
    headers: {
        Authorization : localStorage.getItem('JWT_TOKEN')
    },})
    .then(res=> res.data)};
//用户管理-动态验证码生成-登陆前
export const setEmailCodeBefore = () => { return axios
({method: 'get',
    url: '/api/v1/user/setEmailCode'})
    .then(res=> res.data)};

//用户管理-动态验证码验证
export const SMSValid = (params) => { return axios.get("/api/v1/user/SMSValid?checkCode="+params).then(res=> res.data) };
//机构信息验证
export const orgValid = (params) => { return loginreq("post", "/api/v1/user/valid", params) };
//用户管理-找回用户名
export const getUsername = (params) => { return loginreq("post", "/api/v1/user/getUsername", params) };
//用户管理-找回密码
export const updatePassword = (params) => { return loginreq("put", "/api/v1/user/updatePassword", params) };
//用户管理-修改手机号
export const updateMobile = (params) => { return loginreq("post", "/api/v1/user/updateMobile", params) };
//获取验证码
export const getCode = (params) => { return req("post", "/api/v1/user/getCode", params) };
//用户管理-退出登录
export const logout = (params) => { return req("post", "/api/v1/user/logout", params) };
//用户管理-个人中心
export const getUserInfo = (params) =>
{ return axios
({method: 'get',
    url: '/api/v1/user/getUserInfo?token='+params,
    headers: {
        Authorization : localStorage.getItem('JWT_TOKEN')
    },})
    .then(res=> res.data)};



/**
 * 权限管理 
 **/
//用户管理-user认证授权
export const getUserAuthorization = () => { return axios
({method: 'get',
    url: '/api/v1/user/userAuthorization',
    headers: {
        Authorization : localStorage.getItem('JWT_TOKEN')
    },})
    .then(res=> res.data)};

//用户管理-admin认证授权
export const getAdminAuthorization = () => { return axios
({method: 'get',
    url: '/api/v1/user/adminAuthorization',
    headers: {
        Authorization : localStorage.getItem('JWT_TOKEN')
    },})
    .then(res=> res.data)};